//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2")
#pragma GCC optimize("Ofast","unroll-loops","inline")
#include<bits/stdc++.h>
#define ll long long
//#define int ll
#define pb push_back
#define pii pair<int,int>
#define MP make_pair
#define fi first
#define se second
using namespace std;
const int N=6e6+10,M=1e6+10,mod=998244353;
int fx[]={-1,1,0,0},fy[]={0,0,-1,1};
int H,W,n;
char s[N];
vector<vector<int> > vis,a,LR,RR,r,dis,LC,RC,c;
inline int findr(int i,int x){return x==r[i][x]?x:r[i][x]=findr(i,r[i][x]);}
inline int findc(int i,int x){return x==c[i][x]?x:c[i][x]=findc(i,c[i][x]);}
inline void delc(int i,int y){
	int x=LC[i][y],z=RC[i][y];
	LC[i][z]=x,RC[i][x]=z;
	LC[i][y]=RC[i][y]=0;
	c[i][y]=findc(i,z);
}
inline void delr(int i,int y){
	int x=LR[i][y],z=RR[i][y];
	LR[i][z]=x,RR[i][x]=z;
	LR[i][y]=RR[i][y]=0;
	r[i][y]=findr(i,z);
}
queue<pii> q,p,dl,d;
int x1,y1,x2,y2;
signed main(){
	freopen("stamp.in","r",stdin);
	freopen("stamp.out","w",stdout);
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	cin>>H>>W>>n;
	cin>>x1>>y1>>x2>>y2;
	a.resize(H+1),LR.resize(H+1),RR.resize(H+1),r.resize(H+1);
	dis.resize(H+1);vis.resize(H+1);
	for(int i=1;i<=H;i++){
		a[i].resize(W+1);
		vis[i].resize(W+1);
		dis[i].resize(W+1);
		cin>>s;
		for(int j=1;j<=W;j++) a[i][j]=s[j-1]=='.'; 
	}
	for(int i=1;i<=H;i++){
		LR[i].resize(W+2),RR[i].resize(W+2),r[i].resize(W+2);
		for(int j=1;j<=W;j++) LR[i][j]=j-1,RR[i][j]=j+1,r[i][j]=j;
		r[i][W+1]=W+1;
	}
	LC.resize(W+1),RC.resize(W+1),c.resize(W+1); 
	for(int j=1;j<=W;j++){
		LC[j].resize(H+2),RC[j].resize(H+2),c[j].resize(H+2);
		for(int i=1;i<=H;i++) LC[j][i]=i-1,RC[j][i]=i+1,c[j][i]=i;
		c[j][H+1]=H+1;
	}
	dis[x1][y1]=0;
	q.push(MP(x1,y1));
	delr(x1,y1);vis[x1][y1]=1;
	bool fl=0;
	while(!q.empty()){
		while(!q.empty()){
			pii u=q.front();q.pop();p.push(u);
			int x=u.fi,y=u.se;
//			cout<<x<<' '<<y<<'\n';
			if(x==x2&&y==y2){fl=1;break;}
			for(int i=0;i<4;i++){
				int nx=x+fx[i],ny=y+fy[i];
				if(nx<1||nx>H||ny<1||ny>W) continue;
				if(vis[nx][ny]||!a[nx][ny]) continue;
				dis[nx][ny]=dis[x][y];
				vis[nx][ny]=1;
				q.push(MP(nx,ny));delr(nx,ny);
			}
		}
		if(fl) break;
		while(!p.empty()){
			pii u=p.front();p.pop();
			int x=u.fi,y=u.se;
			int S=findc(y,max(1,x-n+1));
			for(int i=S;i<=min(H,x+n-1);i=RC[y][i]){
				bool flag=0;
				int T=findr(i,max(1,y-n));
				for(int j=T;j<=min(W,y+n);j=RR[i][j]) flag=1,dl.push(MP(i,j));
				if(!flag) d.push(MP(y,i));
			}
			if(x-n>=1){
				int i=x-n;
				int T=findr(i,max(1,y-n+1));
				for(int j=T;j<=min(W,y+n-1);j=RR[i][j]) dl.push(MP(i,j));
			}
			if(x+n<=H){
				int i=x+n;
				int T=findr(i,max(1,y-n+1));
				for(int j=T;j<=min(W,y+n-1);j=RR[i][j]) dl.push(MP(i,j));
			}
			while(!d.empty()){
				u=d.front(),d.pop();
				int ny=u.fi,nx=u.se;
				delc(ny,nx);
			}
			while(!dl.empty()){
				u=dl.front(),dl.pop();
				int nx=u.fi,ny=u.se;
				delr(nx,ny);dis[nx][ny]=dis[x][y]+1;
				if(nx==x2&&ny==y2){fl=1;break;}
				vis[nx][ny]=1;
				q.push(MP(nx,ny));
			}
			if(fl) break;
		}
		if(fl) break;
	}
	cout<<dis[x2][y2]<<'\n';
	return 0;
}
